/*
 * @LastEditTime: 2023-12-22 15:25:04
 * @Description: 菜单路由
 * @Date: 2022-11-10 01:49:18
 */
// 引入图标：https://yesicon.app/material-symbols/
import IconMaterialSymbolsComputerOutline from "~icons/material-symbols/computer-outline";
import IconMaterialSymbolsShieldLockedOutlineRounded from "~icons/material-symbols/shield-locked-outline-rounded";
import IconMaterialSymbolsAccessibilityRounded from "~icons/material-symbols/accessibility-rounded";
import IconMaterialSymbolsChronicOutlineRounded from "~icons/material-symbols/chronic-outline-rounded";
import IconMaterialSymbolsAssistantNavigationOutline from "~icons/material-symbols/assistant-navigation-outline";
import IconMaterialSymbolsErrorCircleRoundedOutlineSharp from "~icons/material-symbols/error-circle-rounded-outline-sharp";
import IconMaterialSymbolsDatabaseOutline from "~icons/material-symbols/database-outline";
import IconMaterialSymbolsCounter1OutlineRounded from "~icons/material-symbols/counter-1-outline-rounded";
import IconMaterialSymbolsRvHookupOutline from "~icons/material-symbols/rv-hookup-outline";
import IconMaterialSymbolsHttp from "~icons/material-symbols/http";
import IconMaterialSymbolsPowerPlugOutline from "~icons/material-symbols/power-plug-outline";
import IconMaterialSymbolsActivityZoneOutline from "~icons/material-symbols/activity-zone-outline";
import IconMaterialSymbolsDocsOutline from "~icons/material-symbols/docs-outline";
import IconMaterialSymbolsPacketMirroring from "~icons/material-symbols/packet-mirroring";
import IconMaterialSymbolsKeyOff from "~icons/material-symbols/key-off";
import IconMaterialSymbolsDeployedCodeAccountOutlineSharp from "~icons/material-symbols/deployed-code-account-outline-sharp";
import IconMaterialSymbolsChecklistRounded from "~icons/material-symbols/checklist-rounded";
import IconMaterialSymbolsAdb from "~icons/material-symbols/adb";
import IconMaterialSymbolsAirplayOutline from "~icons/material-symbols/airplay-outline";
import IconMaterialSymbolsApiRounded from "~icons/material-symbols/api-rounded";
import IconMaterialSymbolsLogoDevSharp from "~icons/material-symbols/logo-dev-sharp";
import IconMaterialSymbolsDnsOutline from "~icons/material-symbols/dns-outline";
import IconMaterialSymbolsSaveOutline from "~icons/material-symbols/save-outline";
import IconMaterialSymbolsDocumentScannerOutlineRounded from "~icons/material-symbols/document-scanner-outline-rounded";
import IconMaterialSymbolsMaterialSymbolsAndroidChat from "~icons/material-symbols/android-chat";
import { markRaw } from "vue";

export const menuRouter = [
  // 开发工具
  {
    path: "devtools",
    name: "DevTools",
    meta: {
      title: "开发工具",
      icon: markRaw(IconMaterialSymbolsComputerOutline),
    },
    redirect: { name: "_devToolsPage" },
    children: [
      {
        path: "devTools",
        name: "_devToolsPage",
        meta: {
          title: "模板页面",
        },
        component: () => import("@/views/devTools/_devToolsPage.vue"),
      },
    ],
  },
  // Shell 处理
  {
    path: "shellHandle",
    name: "ShellHandle",
    meta: {
      title: "Shell 运维",
      icon: markRaw(IconMaterialSymbolsAdb),
    },
    redirect: { name: "ShellExcPage" },
    children: [
      {
        path: "serverRestart",
        name: "ServerRestartPage",
        meta: {
          title: "一键启停",
          icon: markRaw(IconMaterialSymbolsAirplayOutline),
        },
        component: () => import("@/views/shellHandle/ServerRestartPage.vue"),
      },
      {
        path: "autoDeploy",
        name: "AutoDeployPage",
        meta: {
          title: "自动部署",
          icon: markRaw(IconMaterialSymbolsApiRounded),
        },
        component: () => import("@/views/shellHandle/AutoDeployPage.vue"),
      },
      {
        path: "backupServer",
        name: "BackupServerPage",
        meta: {
          title: "服务一键备份",
          icon: markRaw(IconMaterialSymbolsSaveOutline),
        },
        component: () => import("@/views/shellHandle/BackupServerPage.vue"),
      },
      // {
      //   path: "serverMonitor",
      //   name: "ServerMonitorPage",
      //   meta: {
      //     title: "服务器监控",
      //     icon: markRaw(IconMaterialSymbolsDnsOutline),
      //   },
      //   component: () => import("@/views/shellHandle/ServerMonitorPage.vue"),
      // },
      // {
      //   path: "logDesc",
      //   name: "IogDescPage",
      //   meta: {
      //     title: "日志解析",
      //     icon: markRaw(IconMaterialSymbolsLogoDevSharp),
      //   },
      //   component: () => import("@/views/shellHandle/IogDescPage.vue"),
      // },
    ],
  },
];

/**
 * @param { Array } router 路由数组
 * @param { String } parentPath 父级路由 path
 * @description 菜单路由数组 format
 * @return { Array }
 * @Date 2022-11-13 20:18:30
 * @Author isboyjc
 */
export const menuRouterFormat = (router, parentPath) => {
  return router.map((item) => {
    // 拼接路由，例：'devtools' -> '/devtools'  'regular' -> '/devtools/regular'
    item.path = parentPath ? `${parentPath}/${item.path}` : `/${item.path}`;

    // 存在 children 属性，且 children 数组长度大于 0，开始递归
    if (item.children && item.children.length > 0) {
      item.children = menuRouterFormat(item.children, item.path);
    }

    return Object.assign({}, item, item.meta || {});
  });
};

// 解析后 路由菜单列表
export const menuRouterFormatList = menuRouterFormat([...menuRouter]);
